import { PropsWithChildren, ReactNode } from "react";
import { RouteComponentProps } from "react-router-dom";
type HomeProps1 = PropsWithChildren<RouteComponentProps>;

interface HomeProps2 extends RouteComponentProps {
  children?: ReactNode;
}

/* type PropsWithChildren2<P> = P & { children?: string };

interface OldProps {
  name: string;
}
type NewProps = PropsWithChildren2<OldProps>;

let p: NewProps = { name: "zhufeng", children: "jiagou" };

 */
/**
 * interface type 有什么样的相同点,有什么不同点,以及如何选择
 * 1.相同点
 */
///1.type interface都可以描述 对象的形状
interface User {
  name: string;
  age: number;
}

type User2 = {
  name: string;
  age: number;
};
//都可以扩展
interface AdminUser extends User {
  gender: "string";
}
type AdminUser2 = User2 & { gender: "string" };
//不同点
// type可以用来声明基本类型别名  联合类型 元组类型
type Name = string;
type Dog = {};
type Cat = {};
type Pet = Dog | Cat;
type Animals = [Dog, Cat];
let div = document.createElement("div");
type Div = typeof div;

//不同点  interface能合并而type不行
interface Animal {
  name: string;
}
interface Animal {
  age: number;
}
let a: Animal = { name: "", age: 10 };
/* type K1 = {};
type K1 = {}; */
/**
 * interface定义是真实的类型 一个人是真实的类型
 * type 别名 可以组合,可以计算
 * 如果能用interface就不会用type/
 */
//type c = a & b & c & c;
